home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / admin / xinetd.2 / xinetd / xinetd.2.1.7-linux.4 / compile-src < prev    next >
Encoding:
Text File  |  1996-01-24  |  19.4 KB  |  761 lines

  1. #!/bin/sh
  2.  
  3. #
  4. # (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  5. #
  6.  
  7. #
  8. # $Id: compile-src,v 1.15 1996/01/24 19:26:30 chuck Exp $
  9. #
  10.  
  11. script_name=`basename $0`
  12.  
  13. if test "$script_name" != "$0" -a "./$script_name" != "$0" ; then
  14.    echo This script must be executed from the top level directory 
  15.    exit 1
  16. fi
  17.  
  18. XPWD=`pwd`
  19.  
  20. #
  21. # The order with which the libraries are listed is important.
  22. # It is also a problem; to understand why consider this:
  23. #        Library A depends (uses some functions from) library B
  24. #        Then, B must be compiled and installed before A so that
  25. #        A can find B's include files at the standard place.
  26. #        But when linking the program with A and B, if B precedes A
  27. #        then none of B's code will be included since nobody has yet
  28. #        tried to use it (since has not been encountered yet).
  29. #
  30. # Our solution is to list the libraries in the order they are compiled
  31. # and while compiling them also generate the reverse list which is the
  32. # order they have to be linked.
  33. #
  34. mandatory_libs="misc sio pset xlog str"
  35. optional_libs="pq timer"
  36.  
  37. catch_sigs="2 15"
  38. inc=/usr/include
  39.  
  40. #
  41. # The value of ccopt is used for setting the DEBUG makefile variable.
  42. # Therefore, it can be used to either enable debugging support (i.e. -g),
  43. # profiling support (i.e. -pg), or optimization support (i.e. -O)
  44. # The default is optimization.
  45. #
  46. ccopt=-O
  47.  
  48. while test $# -gt 0
  49. do
  50.     option=$1 ; shift
  51.     case $option in
  52.         -libc)
  53.                 if test $# -eq 0 ; then
  54.                     echo "Argument missing. Exiting..."
  55.                     exit 1
  56.                 fi
  57.                 libc=$1
  58.                 shift
  59.                 if test ! -r $libc ; then
  60.                     echo "File is not readable: $libc"
  61.                     exit 1
  62.                 fi
  63.                 ;;
  64.  
  65.         -signals)
  66.                 if test $# -eq 0 ; then
  67.                     echo "Argument missing. Exiting..."
  68.                     exit 1
  69.                 fi
  70.                 signal_handling=$1
  71.                 shift
  72.                 ;;
  73.  
  74.         -ccopt)
  75.                 if test $# -eq 0 ; then
  76.                     echo "Argument missing. Exiting..."
  77.                     exit 1
  78.                 fi
  79.                 ccopt=$1
  80.                 shift
  81.                 ;;
  82.  
  83.         -os)
  84.                 if test $# -eq 0 ; then
  85.                     echo "Argument missing. Exiting..."
  86.                     exit 1
  87.                 fi
  88.                 osversion=$1 ;
  89.                 shift
  90.                 ;;
  91.         
  92.         -auto)
  93.                 autoconfig=yes
  94.                 ;;
  95.  
  96.         -sf|-cf)
  97.                 if test $# -eq 0 ; then
  98.                     echo "Missing argument to $option. Exiting..."
  99.                     exit 1
  100.                 fi
  101.                     
  102.                 if test "$option" = "-sf" ; then
  103.                     v=yes
  104.                 else
  105.                     v=no
  106.                 fi
  107.  
  108.                 specified_flags=yes
  109.                 flag=$1
  110.                 shift
  111.  
  112.                 #
  113.                 # The first 2 lines are for xinetd.
  114.                 # The 3rd line has to do with the man pages (xinetd and libraries)
  115.                 # The rest of the lines are for the libraries
  116.                 #
  117.                 case "$flag" in
  118.                     old_wait|no_rpc|no_termios|no_posix_types)    eval $flag=$v ;;
  119.                     no_siglist)                                                eval $flag=$v ;;
  120.                     has_SB)                                                    eval $flag=$v ;;
  121.                     old_dir|no_ftw|no_timers|no_syslog)                eval $flag=$v ;;
  122.                     has_mmap|has_memops|has_bcopy)                  eval $flag=$v ;;
  123.                     has_isatty|has_bsdtty|has_sysvtty)              eval $flag=$v ;;
  124.                     has_onexit|has_atexit)                          eval $flag=$v ;;
  125.                     *)    echo "Bad flag name: $flag. Exiting..." ; exit 1
  126.                 esac
  127.                 ;;
  128.  
  129.         -custom)
  130.                 custom=yes
  131.                 ;;
  132.  
  133.         -verbose)
  134.                 verbose=yes
  135.                 ;;
  136.         -clean)
  137.                 for makes in $mandatory_libs $optional_libs
  138.                 do
  139.                     cd $XPWD/libs/src/$makes
  140.                     make clean
  141.                 done
  142.                 cd $XPWD/libs/lib
  143.                 /bin/rm -f *.a
  144.                 cd $XPWD/xinetd
  145.                 make clean
  146.                 exit 0
  147.                 ;;
  148.         #
  149.         # THIS IS THE SCRIPT DOCUMENTATION
  150.         #
  151.         -help)
  152.             echo "Usage: $script_name [options]"
  153.             echo "Options:"
  154.             echo "   -libc pathname : specifies the location of the C library"
  155.             echo "   -signals type  : type of signal handling"
  156.             echo "   -os osname     : specifies the OS name and version"
  157.             echo "   -auto          : automatic configuration"
  158.             echo "   -verbose       : display info about configuration"
  159.             echo "   -custom        : there is a custom xinetd configuration file"
  160.             echo "   -ccopt option  : option should be either -g for debugging"
  161.             echo "                    or -O for optimization"
  162.             echo "   -clean         : makes all clean"
  163.             echo "Possible arguments to -signals:"
  164.             echo "         posix, bsd, simple"
  165.             echo "Possible arguments to -os:"
  166.             echo "        sunos4, ultrix4, bsdi1, bsdi2, freebsd2, netbsd1, linux"
  167.             echo "The -sf and -cf options set or clear flags that specify"
  168.             echo "what facilities are available from the operating system"
  169.             echo "Only one flag can be specified per -sf/-cf but these options"
  170.             echo "can be used multiple times."
  171.             echo "Available flags:"
  172.          echo "   no_timers      : BSD-type timers are not available"
  173.          echo "   no_rpc         : system does not support RPC"
  174.          echo "   no_termios     : termios(3) is not available"
  175.          echo "   no_siglist     : sys_siglist(3) is not available"
  176.          echo "   no_ftw         : ftw(3) is not available"
  177.          echo "   no_syslog      : syslog(3) is not available"
  178.          echo "   no_posix_types : POSIX types are not available"
  179.          echo "   has_isatty     : isatty(3) is available"
  180.          echo "   has_bsdtty     : system has BSD-type tty interface"
  181.          echo "   has_sysvtty    : system has SysV-type tty interface"
  182.          echo "   has_mmap       : mmap(2) is available"
  183.          echo "   has_memops     : memops(3) functions are available"
  184.          echo "   has_bcopy      : bcopy(3) is available"
  185.          echo "   has_onexit     : onexit(3) is available"
  186.          echo "   has_atexit     : atexit(3) is available"
  187.          echo "   old_wait       : wait(2) expects a 'union wait' argument"
  188.          echo "   old_dir        : old directory(3) package"
  189.          echo "   has_SB         : system supports .SB in man pages"
  190.          echo
  191.             echo "You can use the -os option to specify an operating system"
  192.             echo "and then you can use -sf/-cf for further mods."
  193.             exit 2
  194.             ;;
  195.  
  196.         *) echo "Bad argument: $1. Exiting..." ; exit 1
  197.     esac
  198. done
  199.  
  200. if test "$autoconfig" != "" -a "$osversion" != "" ; then
  201.     echo "Only one of -auto, -os can be specified"
  202.     exit 1
  203. fi
  204.  
  205. if test ! "$osversion" -a ! "$autoconfig" ; then
  206.     echo "I need to know the operating system you are using and the version."
  207.     echo "I know about"
  208.     echo "   SunOS 4.x     (sunos4)"
  209.     echo "   Ultrix 4.x   (ultrix4)"
  210.     echo "   BSDI 1.x       (bsdi1)"
  211.     echo "   BSDI 2.x       (bsdi2)"
  212.     echo "   FreeBSD 2.x (freebsd2)"
  213.     echo "   NetBSD 1.x   (netbsd1)"
  214.     echo "   Linux 1.x      (linux)"
  215.     echo "If your OS is among these, use the name in the parentheses, otherwise"
  216.     echo "just hit <return> and I will try to figure out how to properly"
  217.     echo -n "configure xinetd for your system --> "
  218.     read osversion
  219. fi
  220.  
  221. #
  222. # This if statement checks if we have a known osversion.
  223. # If we don't, we set the autoconfig flag.
  224. #
  225. if test "$osversion" ; then
  226.     case $osversion in
  227.         sunos4|ultrix4)
  228.             autoconfig= 
  229.             signal_handling=bsd
  230.             ;;
  231.         bsdi1|bsdi2|freebsd2|netbsd1|linux)
  232.             autoconfig=
  233.             signal_handling=posix
  234.             ;;
  235.         *) echo "I don't know anything about this OS. Exiting..." ; exit 1
  236.     esac
  237. else
  238.     autoconfig=yes
  239. fi
  240.  
  241. #
  242. # Get namelist of C library
  243. #
  244. if test "$autoconfig" ; then
  245.     echo "Obtaining name list of C library"
  246.  
  247.     if test ! "$libc" ; then
  248.         if test -r /lib/libc.a ; then
  249.             libc=/lib/libc.a
  250.         else
  251.             if test -r /usr/lib/libc.a ; then
  252.                 libc=/usr/lib/libc.a
  253.             else
  254.                 echo -n "Please give me the pathname of the C library -> "
  255.                 read libc
  256.                 if test ! "$libc" -o ! -r "$libc" ; then
  257.                     echo "Bad pathname. Exiting..."
  258.                     exit 1
  259.                 fi
  260.             fi
  261.         fi
  262.     fi
  263.     nmfile=/tmp/libc.nm.$$
  264.     nm $libc > $nmfile 2>/dev/null
  265.     if test $? -ne 0 ; then
  266.         if test ! -s $nmfile ; then
  267.             echo "Couldn't get the namelist of C library. Exiting..."
  268.             rm -f $nmfile
  269.             exit 1
  270.         else        # name list file is not empty
  271.             echo "WARNING: The 'nm' command returned a non-zero exit status"
  272.             echo "WARNING: so the namelist obtained from the C library may be incomplete"
  273.             echo "Continuing with auto-configuration"
  274.         fi
  275.     fi
  276. fi
  277.  
  278. if test "$specified_flags" -o "$autoconfig" ; then
  279.     lib_defs=
  280.     xinetd_defs=
  281.  
  282.     #
  283.     # Determine supported signal handing
  284.     #
  285.     if test "$autoconfig" -a ! "$signal_handling" ; then
  286.         if test "$verbose" ; then echo "Looking for sigaction" ; fi
  287.         found=`grep sigaction $nmfile | grep T`
  288.         if test "$found" ; then
  289.             signal_handling=posix
  290.         else
  291.             if test "$verbose" ; then echo "Looking for sigvec" ; fi
  292.             found=`grep sigvec $nmfile | grep T`
  293.             if test "$found" ; then 
  294.                 signal_handling=bsd
  295.             else
  296.                 signal_handling=simple
  297.             fi
  298.         fi
  299.     fi
  300.  
  301.     case "$signal_handling" in
  302.         posix)    v= ;;
  303.         bsd)        v="-DNO_POSIX_SIGS" ;;
  304.         simple)    v="-DNO_POSIX_SIGS -DNO_SIGVEC" ;;
  305.     esac
  306.     xinetd_defs="$xinetd_defs $v"
  307.  
  308.     #
  309.     # Check for setitimer(2)
  310.     #
  311.     case "$no_timers" in
  312.         yes)    v=-DNO_TIMERS ;;
  313.         no)    v= ;;
  314.         *)
  315.                 if test "$autoconfig" ; then
  316.                     if test "$verbose" ; then echo "Looking for setitimer" ; fi
  317.                     found=`grep setitimer $nmfile | grep T`
  318.                     if test ! "$found" ; then v=-DNO_TIMERS ; else v= ; fi
  319.                 else
  320.                     v=
  321.                 fi
  322.     esac
  323.     xinetd_defs="$xinetd_defs $v"
  324.  
  325.     #
  326.     # Check for sys_siglist
  327.     #
  328.     case "$no_siglist" in
  329.         yes)    v=-DNO_SIGLIST ;;
  330.         no)    v= ;;
  331.         *)
  332.                 if test "$autoconfig" ; then
  333.                     if test "$verbose" ; then echo "Looking for sys_siglist" ; fi
  334.                     found=`grep sys_siglist $nmfile | grep D`
  335.                     if test ! "$found" ; then v=-DNO_SIGLIST ; else v= ; fi
  336.                 else
  337.                     v=
  338.                 fi
  339.     esac
  340.     xinetd_defs="$xinetd_defs $v"
  341.  
  342.     #
  343.     # Check for RPC
  344.     #
  345.     case "$no_rpc" in
  346.         yes)    v=-DNO_RPC ;;
  347.         no)    v= ;;
  348.         *)
  349.                 if test "$autoconfig" ; then
  350.                     if test "$verbose" ; then echo "Looking for RPC" ; fi
  351.                     found=`grep rpcent $inc/netdb.h`
  352.                     if test ! "$found" ; then v=-DNO_RPC ; else v= ; fi
  353.                 else
  354.                     v=
  355.                 fi
  356.     esac
  357.     xinetd_defs="$xinetd_defs $v"
  358.  
  359.     #
  360.     # Check if this system supports the old wait
  361.     #
  362.     case "$old_wait" in
  363.         yes)    v=-DOLD_WAIT ;;
  364.         no)    v= ;;
  365.         *)
  366.             if test "$autoconfig" ; then
  367.                 if test "$verbose" ; then echo "Looking for WEXITSTATUS" ; fi
  368.                 found=`grep WEXITSTATUS $inc/sys/wait.h`
  369.                 if test ! "$found" ; then v=-DOLD_WAIT ; else v= ; fi
  370.             else
  371.                 v=
  372.             fi
  373.     esac
  374.     xinetd_defs="$xinetd_defs $v"
  375.  
  376.     #
  377.     # Check for pid_t
  378.     # 
  379.     case "$no_posix_types" in
  380.         yes)    v=-DNO_POSIX_TYPES ;;
  381.         no)    v= ;;
  382.         *)
  383.             if test "$autoconfig" ; then
  384.                 if test "$verbose" ; then echo "Looking for pid_t" ; fi
  385.                 found=`cd $inc/sys ; grep pid_t *.h | grep typedef`
  386.                 if test ! "$found" ; then v=-DNO_POSIX_TYPES ; else v= ; fi
  387.             else
  388.                 v=
  389.             fi
  390.     esac
  391.     xinetd_defs="$xinetd_defs $v"
  392.  
  393.     #
  394.     # Check for termios
  395.     #
  396.     case "$no_termios" in
  397.         yes)    v=-DNO_TERMIOS ;;
  398.         no)    v= ;;
  399.         *)
  400.             if test "$autoconfig" ; then
  401.                 if test -r $inc/sys/termios.h -o -r $inc/termios.h ; then
  402.                     v=
  403.                 else
  404.                     v=-DNO_TERMIOS
  405.                 fi
  406.             else
  407.                 v=
  408.             fi
  409.     esac
  410.     xinetd_defs="$xinetd_defs $v"
  411.  
  412.     #
  413.     # Check for new directory types
  414.     #
  415.     case "$old_dir" in
  416.         yes)    v=-DOLD_DIR ;;
  417.         no)    v= ;;
  418.         *)
  419.                 if test "$autoconfig" ; then
  420.                     if test -r $inc/dirent.h ; then
  421.                         v=
  422.                     else
  423.                         v=-DOLD_DIR
  424.                     fi
  425.                 else
  426.                     v=
  427.                 fi
  428.     esac
  429.     lib_defs="$lib_defs $v"
  430.  
  431.     #
  432.     # Check for ftw(3)
  433.     #
  434.     case "$no_ftw" in
  435.         yes)    v=-D__FTWX_NO_FTW ;;
  436.         no)    v= ;;
  437.         *)
  438.                 if test "$autoconfig" ; then
  439.                     if test -r $inc/ftw.h ; then 
  440.                         v=
  441.                     else
  442.                         v=-D__FTWX_NO_FTW
  443.                     fi
  444.                 else
  445.                     v=
  446.                 fi
  447.     esac
  448.     lib_defs="$lib_defs $v"
  449.  
  450.     #
  451.     # Check for syslog(3)
  452.     #
  453.     case "$no_syslog" in
  454.         yes)    v=-DNO_SYSLOG ;;
  455.         no)    v= ;;
  456.         *)
  457.                 if test "$autoconfig" ; then
  458.                     if test "$verbose" ; then echo "Looking for syslog" ; fi
  459.                     found=`grep syslog $nmfile | grep T`
  460.                     if test ! "$found" ; then v=-DNO_SYSLOG ; else v= ; fi
  461.                 else
  462.                     v=
  463.                 fi
  464.     esac
  465.     lib_defs="$lib_defs $v"
  466.  
  467.     #
  468.     # Check for mmap. Since it is not required, we do not try to find
  469.     # if the system supports it.
  470.     #
  471.     case "$has_mmap" in
  472.         yes)  v=-DHAS_MMAP ;;
  473.         *)    v= ;;
  474.     esac
  475.     lib_defs="$lib_defs $v"
  476.  
  477.    case "$has_onexit" in
  478.       yes)  v=-DHAS_ONEXIT ;;
  479.       no)   v= ;;
  480.       *)
  481.             if test "$autoconfig" ; then
  482.                if test "$verbose" ; then echo "Looking for on_exit" ; fi
  483.                found=`grep on_exit $nmfile | grep T`
  484.                if test "$found" ; then v=-DHAS_ONEXIT ; else v= ; fi
  485.             else
  486.                v=
  487.             fi
  488.    esac
  489.    lib_defs="$lib_defs $v"
  490.  
  491.    case "$has_atexit" in
  492.       yes)  v=-DHAS_ATEXIT ;;
  493.       no)   v= ;;
  494.       *)
  495.             if test "$autoconfig" ; then
  496.                if test "$verbose" ; then echo "Looking for atexit" ; fi
  497.                found=`grep atexit $nmfile | grep T`
  498.                if test "$found" ; then v=-DHAS_ATEXIT ; else v= ; fi
  499.             else
  500.                v=
  501.             fi
  502.    esac
  503.    lib_defs="$lib_defs $v"
  504.  
  505.    case "$has_memops" in
  506.       yes)  v=-DHAS_MEMOPS ;;
  507.       no)   v= ;;
  508.       *)
  509.             if test "$autoconfig" ; then
  510.                if test "$verbose" ; then echo "Looking for memcpy" ; fi
  511.                found=`grep memcpy $nmfile | grep T`
  512.                if test "$found" ; then v=-DHAS_MEMOPS ; else v= ; fi
  513.             else
  514.                v=
  515.             fi
  516.    esac
  517.    lib_defs="$lib_defs $v"
  518.  
  519.    case "$has_bcopy" in
  520.       yes)  v=-DHAS_BCOPY ;;
  521.       no)   v= ;;
  522.       *)
  523.             if test "$autoconfig" ; then
  524.                if test "$verbose" ; then echo "Looking for bcopy" ; fi
  525.                found=`grep bcopy $nmfile | grep T`
  526.                if test "$found" ; then v=-DHAS_BCOPY ; else v= ; fi
  527.             else
  528.                v=
  529.             fi
  530.    esac
  531.    lib_defs="$lib_defs $v"
  532.  
  533.    case "$has_isatty" in
  534.       yes)  v=-DHAS_ISATTY ;;
  535.       no)   v= ;;
  536.       *)
  537.             if test "$autoconfig" ; then
  538.                if test "$verbose" ; then echo "Looking for isatty" ; fi
  539.                found=`grep bcopy $nmfile | grep T`
  540.                if test "$found" ; then v=-DHAS_ISATTY ; else v= ; fi
  541.             else
  542.                v=
  543.             fi
  544.    esac
  545.    #
  546.    # Since SIO cannot compile without the isatty function, if isatty is not
  547.    # in the C library, we have to provide our own. For this, we need to know
  548.    # if the system supports BSD or SysV tty handling.
  549.    #
  550.    if test ! "$osversion" -a ! "$v" ; then
  551.       while test ! "$v"
  552.       do
  553.          echo "Is your OS based on System V or on BSD 4.x ? I am really"
  554.          echo -n "interested in terminal handling. You can say sysv or bsd -->"
  555.          read ans
  556.          case $ans in
  557.             sysv) v=-DHAS_SYSVTTY ;;
  558.             bsd)  v=-DHAS_BSDTTY ;;
  559.             *) echo "Please say either 'sysv' or 'bsd'"
  560.          esac
  561.       done
  562.    fi
  563.    lib_defs="$lib_defs $v"
  564. fi
  565.  
  566. if test "$autoconfig" ; then
  567.     rm -f $nmfile
  568. fi
  569.  
  570. #
  571. # If we know the OS, we can provide the appropriate flags for SIO
  572. #
  573. case "$osversion" in
  574.    sunos4)  sio_defs="-DHAS_MMAP -DHAS_ONEXIT -DHAS_MEMOPS -DHAS_ISATTY"
  575.         cp $XPWD/libs/src/misc/Makefile-2.1.4 $XPWD/libs/src/misc/Makefile
  576.         cp $XPWD/xinetd/Makefile-2.1.4 $XPWD/xinetd/Makefile
  577.             ;;
  578.    ultrix4) sio_defs="-DHAS_MEMOPS -DHAS_ATEXIT -DHAS_ISATTY"
  579.         cp $XPWD/libs/src/misc/Makefile-2.1.4 $XPWD/libs/src/misc/Makefile
  580.         cp $XPWD/xinetd/Makefile-2.1.4 $XPWD/xinetd/Makefile
  581.             ;;
  582.    bsdi1)   sio_defs="-D__FTWX_NO_FTW -DHAS_MMAP -DHAS_ATEXIT -DHAS_BCOPY -DHAS_ISATTY"
  583.         lib_defs="$sio_defs"
  584.        xinetd_defs="-DNO_TERMIOS -DBIND_IF"
  585.         cp $XPWD/libs/src/misc/Makefile-2.1.4 $XPWD/libs/src/misc/Makefile
  586.         cp $XPWD/xinetd/Makefile.bsdi $XPWD/xinetd/Makefile
  587.          CC=cc; export CC
  588.             ;;
  589.    bsdi2)   sio_defs="-D__FTWX_NO_FTW -DHAS_MMAP -DHAS_ATEXIT -DHAS_BCOPY -DHAS_ISATTY"
  590.         lib_defs="$sio_defs"
  591.        xinetd_defs="-DBIND_IF"
  592.         cp $XPWD/libs/src/misc/Makefile-2.1.4 $XPWD/libs/src/misc/Makefile
  593.         cp $XPWD/xinetd/Makefile.bsdi $XPWD/xinetd/Makefile
  594.          CC=shlicc2; export CC
  595.             ;;
  596.    freebsd2)   sio_defs="-D__FTWX_NO_FTW -DHAS_MMAP -DHAS_ATEXIT -DHAS_BCOPY -DHAS_ISATTY"
  597.         lib_defs="$sio_defs"
  598.        xinetd_defs="-DBIND_IF"
  599. #    We do this differently for FreeBSD to add ecvt(), fcvt(), and gcvt()
  600.         cp $XPWD/libs/src/misc/Makefile.freebsd $XPWD/libs/src/misc/Makefile
  601.         cp $XPWD/xinetd/Makefile.freebsd $XPWD/xinetd/Makefile
  602.             ;;
  603.    netbsd1)   sio_defs="-D__FTWX_NO_FTW -DHAS_MMAP -DHAS_ATEXIT -DHAS_BCOPY -DHAS_ISATTY"
  604.         lib_defs="$sio_defs"
  605.        xinetd_defs="-DBIND_IF"
  606. #    We do this differently for NetBSD to add ecvt(), fcvt(), and gcvt()
  607.         cp $XPWD/libs/src/misc/Makefile.freebsd $XPWD/libs/src/misc/Makefile
  608.         cp $XPWD/xinetd/Makefile.netbsd $XPWD/xinetd/Makefile
  609.             ;;
  610.    linux)   sio_defs="-D__FTWX_NO_FTW -DHAS_MMAP -DHAS_ATEXIT -DHAS_BCOPY -DHAS_ISATTY"
  611.         lib_defs="$sio_defs"
  612.        xinetd_defs="-DBIND_IF"
  613.         cp $XPWD/libs/src/misc/Makefile-2.1.4 $XPWD/libs/src/misc/Makefile
  614.         cp $XPWD/xinetd/Makefile.linux $XPWD/xinetd/Makefile
  615.             ;;
  616.    *)       sio_defs="$lib_defs"
  617. esac
  618.  
  619. case "$no_timers" in
  620.     yes) lib_names="$mandatory_libs" ;;
  621.     *)
  622.         case "$signal_handling" in
  623.             posix)    lib_names="$mandatory_libs $optional_libs" ;;
  624.             bsd)        lib_names="$mandatory_libs $optional_libs"
  625.                         lib_defs="$lib_defs -DNO_POSIX_SIGS"
  626.                         ;;
  627.             *)            lib_names="$mandatory_libs"
  628.         esac
  629. esac
  630.  
  631. incdir=$XPWD/libs/include
  632. mandir=$XPWD/libs/man
  633. libdir=$XPWD/libs/lib
  634.  
  635. #
  636. # Only Suns undestand .SB in man pages, so if we are not dealing with
  637. # a Sun we replace .SB with .B
  638. #
  639. if test "$osversion" = "sunos4" ; then
  640.     modify_manpages=
  641. else
  642.     case "$has_SB" in
  643.         yes) modify_manpages= ;;
  644.         no)  modify_manpages=yes ;;
  645.         *)
  646.         echo -n "Can your machine handle .SB in a man page ? (if you are not sure, say no) -->"
  647.         read x
  648.         if test "$x" = "n" -o "$x" = "no" ; then
  649.             modify_manpages=yes
  650.         else
  651.             modify_manpages=
  652.         fi
  653.     esac
  654. fi
  655.  
  656. if test "$modify_manpages" ; then
  657.     #
  658.     # We can't take any interrupts while processing the manpages
  659.     #
  660.     trap 'interrupt_occured=yes' $catch_sigs
  661.  
  662.     echo "Replacing .SB in library man pages with .B (if a man page is changed"
  663.     echo "the original will be kept by appending .orig to its name)"
  664.     for i in $lib_names
  665.     do
  666.         cd $XPWD/libs/src/$i
  667.         for i in *.3
  668.         do
  669.             mv $i $i.orig                                            # save the original
  670.             sed 's/[.]SB/.B/' $i.orig > $i                    # do the replacement
  671.             cmp -s $i $i.orig                                        # are they the same ?
  672.             if test $? -eq 0 ; then rm $i.orig ; fi        # if yes, remove the copy
  673.         done
  674.         if test "$interrupt_occured" = "yes" ; then
  675.             echo "Interrupt: quiting"
  676.             exit 1
  677.         fi
  678.     done
  679.  
  680.     trap $catch_sigs        # no more trapping
  681. fi
  682.  
  683. #
  684. # Make the libraries
  685. # Also prepare the value of the LIBS variable in the xinetd Makefile
  686. #
  687. mvars="DEBUG=$ccopt MANDIR=$mandir INCLUDEDIR=$incdir LIBDIR=$libdir"
  688. for i in $lib_names
  689. do
  690.     libs="-l$i $libs"
  691.     cd $XPWD/libs/src/$i
  692.     echo Making library: $i
  693.     #
  694.     # Remove the archive if it is already there; this is to avoid ld complaints
  695.     # that the table of contents is out of date.
  696.     #
  697.     rm -f lib$i.a
  698.     if test "$i" = "sio" ; then
  699.         make $mvars DEFS="$sio_defs" install
  700.     else
  701.         make $mvars DEFS="$lib_defs" install
  702.     fi
  703.     if test $? -ne 0 ; then
  704.         echo "Failed to create library: $i"
  705.         exit 2
  706.     fi
  707. done
  708.  
  709. #
  710. # Now make xinetd
  711. # We remove the xinetd executable, if there is one, in case the libraries
  712. # have changed
  713. #
  714. cd $XPWD/xinetd
  715. rm -f xinetd
  716. mvars="DEBUG=$ccopt INCLUDEDIR=-I$incdir LDFLAGS=-L$libdir"
  717. if test "$custom" ; then xinetd_defs="$xinetd_defs -DCUSTOMCONF" ; fi
  718.  
  719. case "$osversion" in
  720.     bsdi1|bsdi2)
  721.         make "DEFS=$xinetd_defs" "LIBS=$libs -lrpc -lcompat" $mvars
  722.         ;;
  723.     freebsd2)
  724.         make "DEFS=$xinetd_defs" "LIBS=$libs -lrpcsvc -lcrypt -lcompat -lm" $mvars
  725.         ;;
  726.     netbsd1)
  727.         make "DEFS=$xinetd_defs" "LIBS=$libs -lrpcsvc -lcrypt -lcompat -lm" $mvars
  728.         ;;
  729.     linux)
  730.         make "DEFS=$xinetd_defs" "LIBS=$libs" $mvars
  731.         ;;
  732.     *)
  733.         make "DEFS=$xinetd_defs" "LIBS=$libs -lcompat" $mvars
  734. esac
  735.  
  736. if test $? -ne 0 ; then
  737.     echo Failed to create xinetd
  738.     exit 2
  739. fi
  740.  
  741. if test "$modify_manpages" ; then
  742.  
  743.     trap 'interrupt_occured=yes' $catch_sigs
  744.  
  745.     echo "Replacing .SB in xinetd man pages with .B"
  746.     for i in *.man
  747.     do
  748.         mv $i $i.orig
  749.         sed 's/[.]SB/.B/' $i.orig > $i
  750.         cmp -s $i $i.orig                                        # are they the same ?
  751.         if test $? -eq 0 ; then rm $i.orig ; fi        # if yes, remove the copy
  752.  
  753.         if test "$interrupt_occured" = "yes" ; then
  754.             echo "Interrupt: quiting"
  755.             exit 1
  756.         fi
  757.     done
  758.     trap $catch_sigs        # no more trapping
  759. fi
  760.  
  761.